﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DIST.LR.ZHJG.Events;
using HSE.Events;
using HSE.Common;
using PetroMentor.Service;

namespace HSE
{
    public partial class Banner : UserControl
    {
        BannerViewModel viewmodel;

        public Banner()
        {
            InitializeComponent();
            viewmodel = new BannerViewModel();
            viewmodel.SysName = SystemVar.SysInfoCollection.FirstOrDefault(item=> item.IsCurrent ==true).SysName;
            this.DataContext = viewmodel;
            EventAggregatorRepository.EventAggregator.GetEvent<HSE.Events.LoginClickEvent>().Subscribe(LoginHandler);
        }

        public void LoginHandler(T_CFG_USER user)
        {
            viewmodel.SysName = SystemVar.SysInfoCollection.FirstOrDefault(item => item.IsCurrent == true).SysName;
        }

        private void RadToggleButton_Checked(object sender, RoutedEventArgs e)
        {
            EventAggregatorRepository.EventAggregator.GetEvent<NaviMainMenuClickEvent>().Publish("show");
        }

        private void RadToggleButton_Unchecked(object sender, RoutedEventArgs e)
        {
            EventAggregatorRepository.EventAggregator.GetEvent<NaviMainMenuClickEvent>().Publish("hidden");
        }

        private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            EventAggregatorRepository.EventAggregator.GetEvent<LoginOutClickEvent>().Publish("LoginOut");
            
        }
    }
}
